﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Redis订阅模式DEMO
{
    class Program
    {
        static void Main(string[] args)
        {
            var resis = new Redis数据订阅();

            while (true)
            {
                Console.WriteLine("请输入订阅线程数:每秒发生成数据最大值格式 n:n");
                string[] str = Console.ReadLine().Split(':');
                int pub = 1;
                int ss = 1000;
                if (str.Length > 1)
                {
                    if (int.TryParse(str[0], out pub))
                    {
                        if (int.TryParse(str[1], out ss))
                        {
                            resis.IsCanRuning = true;
                            //线程调用
                            System.Threading.Thread thre = new System.Threading.Thread(() =>
                            {
                                resis.接收订阅数据(pub, ss);
                            });
                            thre.Start();
                        }
                    }
                }
                while (true)
                {
                    Console.WriteLine("请输入'C'停止");
                    string sstr = Console.ReadLine();
                    if (sstr == "C")
                    {
                        resis.IsCanRuning = false;
                        break;
                    }

                }
            }

        }
    }
}
